#include "CChatServer.h"

#include "CChatHandler.h"


CChatServer::CChatServer(QHostAddress add, qint16 port, QObject *parent):QTcpServer(parent)
{
    connect(this,SIGNAL(newConnection()),this,SLOT(onNewConnection()));
    if(!listen(add,port))
        throw(this->errorString().toStdString());

    _chatHandler=new CChatHandler(this,parent);
}

void CChatServer::onNewConnection()
{
    QTcpSocket*connec=this->nextPendingConnection();
    new CChatSession(this,connec);
}
